home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: howland.reston.ans.net!psinntp!psinntp!psinntp!psinntp!bbnews1!trsvr!news
- From: "Benjamin M. Romer" <bmr1@trpo4.tr.unisys.com>
- Subject: Re: Fahrenheight to Celsius?
- Sender: news@tr.unisys.com (cnews news id.)
- Message-ID: <DMvMCv.KzA@tr.unisys.com>
- Date: Fri, 16 Feb 1996 16:12:31 GMT
- X-Nntp-Posting-Host: bmr1.tr.unisys.com
- Content-Transfer-Encoding: 7bit
- Content-Type: text/plain; charset=us-ascii
- References: <4fra3q$ddt@newsbf02.news.aol.com> <4fvthq$2bl@newserv.agcs.com>
- Mime-Version: 1.0
- X-Mailer: Mozilla 1.1 (Windows; U; 16bit)
- Organization: Unisys Corporation
-
- okay.. here goes nothing:
-
- #include <iostream.h>
-
- class Celcius;
-
- class Farenheight
- {
- private:
- double temp;
- public:
- Farenheight(double tmp)
- :temp(tmp)
- {}
- Celcius operator Celcius()
- {
- return Celcius((temp - 32) / 2.5);
- }
- friend ostream & operator << (ostream &os, Farenheight ftmp)
- {
- os << ftmp.temp << "F"; return os;
- }
- };
-
- class Celcius
- {
- private:
- double temp;
- public:
- Celcius(double tmp)
- :temp(tmp)
- {}
- Farenheight operator Farenheight()
- {
- return Farenheight((temp * 2.5) + 32);
- }
- friend ostream & operator << (ostream &os, Celcius ctmp)
- {
- os << ctmp.temp << "C"; return os;
- }
- };
-
- int main()
- {
- Farenheight convert(150.0);
- Celcius fToC(convert);
-
- cout << convert << " in Celcius is " << fToC << "!\n";
- cout << "I hope this is complicated enough to convince your Prof "
- "That you didn't write it yourself.\n";
-
- return 0;
- }
-
-
-
- :)
-
- Benjamin M. Romer
- Software Engineer
- Unisys Corporation
-
- #include <stddisclaim.h>
-
-
-